import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sml_policies/locator/locator.dart';
import 'package:sml_policies/locator/sml_policies.dart';
import 'package:sml_policies/ui/widgets/app_button.dart';

import 'animate.dart';

class ExitConfirmDialog extends Dialog {
  ExitConfirmDialog({super.key,
    this.onCancel,
    this.onConfirm
  });

  final Function? onCancel;
  final Function? onConfirm;

  final SmlPoliciesConfig smlPoliciesConfig = locator<SmlPoliciesConfig>();

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 310.w,
        height: 204.h,
        padding: const EdgeInsets.all(15),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20),
          color: Colors.white
        ),
        child: Material(
          color: Colors.white,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text(smlPoliciesConfig.languageMap['refuseConfirm'],
                  style: const TextStyle(fontSize: 16, color: Color(0xFF333333))),
              SizedBox(height: 20.h),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  SizedBox(
                    width: 130.w,
                    height: 40.h,
                    child: AppButton(
                      content: smlPoliciesConfig.languageMap['agree'],
                      color: Colors.grey,
                      style: TextStyle(fontSize: 17.sp, color: Colors.white),
                      onTap: () {
                        onConfirm?.call();
                        Navigator.pop(context);
                      },
                    )
                    // child: btn(
                    //   Text(smlPoliciesConfig.languageMap['agree'], style: TextStyle(fontSize: 17.sp, color: Colors.white)),
                    //   color: Colors.grey,
                    //   onPress: () {
                    //     onConfirm?.call();
                    //     Navigator.pop(context);
                    //   },
                    // ),
                  ),
                  SizedBox(
                    width: 130.w,
                    height: 40.h,
                    child: AppButton(
                      content: smlPoliciesConfig.languageMap['deny'],
                      // color: Colors.grey,
                      style: TextStyle(fontSize: 17.sp, color: Colors.white),
                      onTap: () {
                        onCancel?.call();
                        Navigator.pop(context);
                      },
                    )
                    // child: btn(
                    //   Text(smlPoliciesConfig.languageMap['deny'], style: TextStyle(fontSize: 17.sp, color: Colors.white)),
                    //   onPress: () {
                    //     onCancel?.call();
                    //     Navigator.pop(context);
                    //   },
                    // ),
                  ),
                ],
              )
            ],
          ),
        ),
      ),
    );
  }

  // Widget btn(Text content, { Color? color, Function? onPress }) {
  //   return GestureDetector(
  //     onTap: () {
  //       onPress?.call();
  //     },
  //     child: Container(
  //       alignment: Alignment.center,
  //       decoration: BoxDecoration(
  //         color: smlPoliciesConfig.mainColor,
  //         borderRadius: BorderRadius.circular(45),
  //       ),
  //       child: content,
  //     ),
  //   );
  // }

  Future show(BuildContext context) async {
    await showAnimDialog(context, ExitConfirmDialog(onConfirm: onConfirm, onCancel: onCancel));
  }

}
